<div class="crumb-wrap">
    <div class="crumb-list"> <i class="icon-font"></i>
        <a href="<?=site_url()?>">首页</a>
        <span class="crumb-step">&gt;</span>
        <a class="crumb-name" href="<?=site_url('project')?>">项目管理</a>
        <span class="crumb-step">&gt;</span>
        <span>项目参数</span>
    </div>
</div>
<div class="search-wrap">
    <div class="search-content" style="margin-left: 20px">
        <a href="<?=site_url('project/update?pid='.$pid)?>" class="btn btn6 mr10">项目修改</a>
        <a href="javascript:;" class="btn btn6 btn-primary mr10">设置参数</a>
        <!-- <a href="<?=site_url('fill/index?pid='.$pid)?>" class="btn btn6 mr10">客户填写</a> -->
    </div>
</div>
<div class="result-wrap">
    <form name="myform" id="myform" method="post">
        <div class="result-title">
            <div class="result-list">
                <a href="<?=site_url('parameters/create?pid='.$pid)?>"> <i class="icon-font"></i>
                    新增属性
                </a>
            </div>
        </div>
        <div class="result-content">
            <table class="result-tab" width="100%">
                <tr>
                    <th>排序</th>
                    <th>ID</th>
                    <th>属性名称</th>
                    <?php foreach($list_group as $k => $v): ?>
                    <th><?=$v['title']?></th>
                    <?php endforeach;?>
                    <th>默认价格</th>
                    <th>更新时间</th>
                    <th>操作</th>
                </tr>

                <?php foreach($list as $k => $v):?>
                <tr>
                    <td>
                        <input class="common-input sort-input" value="<?=$v['sort']?>" type="text" onclick="set_sort(<?=$v['id']?>,<?=$v['sort']?>)" readonly="readonly">
                    </td>
                    <td><?=$v['id']?></td>
                    <td title="<?=$v['title']?>">
                        <a href="javascript:;" onclick="open_view('<?=site_url('article/show?aid='.$v['article_id'])?>')"><?=$v['title']?></a>
                    </td>
                    <?php foreach($list_group as $key => $value): ?>
                        <?php if(empty($list_price[$v['id']][$value['id']]['price'])):?>
                            <td style="color:red" title="没有设置价格"><?=$v['price']?></td>
                        <?php else:?>
                            <td><?=$list_price[$v['id']][$value['id']]['price']?></td>
                        <?php endif;?>
                    <?php endforeach;?>

                    <td><?=$v['price']?></td>
                    <td><?=date('Y-m-d H:i:s',$v['update_time'])?></td>
                    <td>
                        <a class="link-update" href="<?=site_url('parameters/update?pid='.$v['id'])?>">修改</a>
                        <a class="link-del" href="javascript:;" onclick="del_par(<?=$v['id']?>)">删除</a>
                    </td>
                </tr>
                <?php endforeach;?>
            </table>
        </div>
    </form>
</div>

<script type="text/javascript">
    layer.config({
        extend: 'extend/layer.ext.js'
    });
    function open_view(url){
        layer.open({
            type: 2,
            area: ['800px', '600px'],
            fix: false, //不固定
            maxmin: true,
            content: url
        });
    }

    /**
     * 删除属性
     */
    function del_par(pid){
        layer.confirm('删除之后不可恢复，是否确定？', {
            btn: ['确定','取消'] //按钮
        }, function(){
            $.post("<?=site_url('parameters/delete')?>",{pid:pid},function(data){
                if(data == 1){
                    layer.alert("操作成功！",{
                        icon:1,
                    },function(){
                        location.reload();
                    });
                }else{
                    layer.alert(data,{
                        icon:2,
                    });
                }
            });
        });
    }

    /**
     * 修改项目排序
     */
    function set_sort(pid,val){
        layer.prompt({
            title: '输入数值（数值大的靠前）',
            value:val
        }, function(sort){
            $.post("<?=site_url('parameters/set_sort')?>",{pid:pid,sort:sort},function(data){
                if(data == 1){
                    layer.alert("操作成功！",{
                        icon:1,
                    },function(){
                        location.reload();
                    });
                }else{
                    layer.alert(data,{
                        icon:2,
                    });
                }
            });
        });
    }
</script>